< previous page page_345 next page >

Page 345
The trick to dealing with these data types is to keep two things in mind:
7017a6ead0e3c4111b47a554df321e9f.gif
It's all an illusionC actually has very few data types.
7017a6ead0e3c4111b47a554df321e9f.gif
Each data type includes the key to decode its meaning.
Let's take a look at the C data types you will run intosee Table T6-2.
TYPEBYTESSIGNRANGE
char1Signed128 to 127
unsigned char1Unsigned0 to 255
short2Signed32768 to 32767
unsigned short2Unsigned0 to 65535
long4Signed2147483648 to 2147483647
unsigned long4Unsigned0 to 4294967295
int4SignedSame as long under Win32
unsigned int4UnsignedSame as unsigned long under Win32
float4Signed±1.4E-45 to ±3.4E38
double8Signed±4.9E-324 to ±1.7E308
class*Varies depending on definition
struct*Varies depending on definition
void0NoneIndicates no type. A function that returns a void is like a VB Subit has no return value.
Table T6-2: C data types

There is also a long double data type and an_intxx type where xx is the size of the integer. These types are rarely usedin fact, I have yet to see them used in any API or DLL function.
You may be wondering, where are the string data types? What about objects and variants? What about Boolean variables?
The trick is in the way the C/C++ language allows you to derive new data types from these native types. Once you derive a new data type, the new type can be used just like those that are built into the language. You'll see how new data types are declared shortly.
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
1 The C++ language is based on the C language and is essentially identical from the point of view of a Visual Basic programmer. For this reason, C and C++ are used interchangeably in this book. As for declarations being intimidatingthe complex ones can be nearly incomprehensible. In fact, this book was inspired in part by a book called The C Puzzle Book, which consisted largely of complex type declarations the reader had to struggle to understand.

 
< previous page page_345 next page >